import request from "./request";

// 登录返回token
export const adminLoginApi = (data: AdminLoginParams): PromiseRes<AdminLoginRes> => request.post('/admin/login', data);

// 虎丘当前登录用户信息
export const getAdminInfoApi = (): PromiseRes<AdminInfoRes> => request.get('/admin/info');

// 获取用户数据列表
export const getAdminListApi = (data: AdminListParams): PromiseRes<AdminListRes> => request.get('/admin/list', {params: data});

// 修改用户信息
export const updateAdminInfoApi = (id: number, data: AdminObjItf): PromiseRes => request.post(`/admin/update/${id}`, data)

// 获取用户的角色信息
export const getAdminRoleApi = (id: number): PromiseRes<RoleObjItf[]> => request.get(`/admin/role/${id}`)

// 获取所有角色信息
export const getRolesApi = (): PromiseRes<RoleObjItf[]> => request.get('/role/listAll')

// 给用户分配角色
export const updateAdminRoleApi = (data: { adminId: number, roleIds: number[] }): PromiseRes => request.post(`/admin/role/update?adminId=${data.adminId}&roleIds=${data.roleIds}`)

// 获取首页数据
export const getAdminStat = (): PromiseRes<IndexData> => request.get('http://kumanxuan1.f3322.net:8360/admin/stat')

